package com.nchu.student_score.controller;

import com.github.pagehelper.PageInfo;
import com.nchu.student_score.dataObject.StudentResult;
import com.nchu.student_score.model.Student;
import com.nchu.student_score.model.Teacher;
import com.nchu.student_score.service.StudentService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    StudentService studentService;

    @RequestMapping("getStudents/{currPage}")
    public PageInfo<StudentResult> getStudentList(@RequestBody StudentResult input, @PathVariable Integer currPage){
        return studentService.getStudentList(input,currPage);
    }

    @RequestMapping("initStudentPwd")
    public ResultVo<Student> initStudentPwd(@RequestBody Student student){
        return studentService.initStudentPwd(student);
    }

    @RequestMapping("updateStudent/{oldStuId}")
    public ResultVo<Student> updateStudent(@RequestBody Student student, @PathVariable Integer oldStuId){
        return studentService.updateStudent(student,oldStuId);
    }

    @RequestMapping("findStudent/{stuId}")
    public ResultVo<StudentResult> findStudent(@PathVariable Integer stuId){
        return studentService.findStudent(stuId);
    }
}
